package com.sky.mapper;

import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

@Mapper

public interface ShoppingCartMapper {
    /**
     * 插入购物车
     * @param shoppingCart
     * @return
     */
    @Insert("insert into shopping_cart (name, image, user_id, dish_id, setmeal_id, dish_flavor, amount, create_time) " +
            "values (#{name},#{image}, #{userId}, #{dishId}, #{setmealId}, #{dishFlavor}, #{amount}, #{createTime});")
    int insert(ShoppingCart shoppingCart);


    /**
     * 多条件查询购物车
     * @param shoppingCart
     * @return
     */
    List<ShoppingCart> list(ShoppingCart shoppingCart);

    /**
     * 增加或减少购物车（更新购物车）
     * @param shoppingCart
     * @return
     */
    int update(ShoppingCart shoppingCart);

    /**
     * 根据用户id删除
     * @param currentId
     * @return
     */
    @Delete("delete from shopping_cart where user_id=#{currentId};")
    int deleteByUserId(Long currentId);
}
